package com.cskaoyan.utils;

import com.cskaoyan.model.admin.bo.ListBo;
import com.cskaoyan.model.admin.vo.AdBaseData;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @description: TODO
 * @author: jiaolei
 * @date: 2021/12/2 15:10
 */
public class BaseDataOnListUtil {
    public static <T> AdBaseData getAdBaseData(ListBo listBo, List<T> t) {
        PageHelper.startPage(listBo.getPage(), listBo.getLimit());
        PageInfo pageInfo = new PageInfo(t);
        long total = pageInfo.getTotal();

        Integer pages=null;
        if(listBo.getLimit()!=null&& listBo.getLimit()!=0){
            pages=t.size()/ listBo.getLimit()+1;
        }
        return AdBaseData.list(t, listBo.getPage(), listBo.getLimit(),total,pages);
    }
}
